package pe.edu.upc.dew.grupo02.dao;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import java.sql.Statement;

import org.apache.commons.dbutils.DbUtils;

public class JdbcUtils {

	public static Connection getConnection() {
		Connection connection=null;
		try {
			Class.forName("org.hsqldb.jdbc.JDBCDriver");
			connection = DriverManager.getConnection("jdbc:hsqldb:mem:test","sa","");
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block.
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return connection;
	}

	public static void create(){
		Connection connection=getConnection();
		try {
			Statement statement = connection.createStatement();
			statement.execute("create table pelicula(CoPelicula int primary key,Nombre varchar(50))");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DbUtils.closeQuietly(connection);
		}
	}
}
